//
// Created by 刘振舟 on 2024/3/18.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>
#include "uthash.h"

typedef struct {
    char key;
    int value;
    UT_hash_handle hh;
}HashMap;


int getValueFromHashMap(HashMap *map, char* key) {
    HashMap* temp;
    HASH_FIND(hh, map, key, sizeof(char ), temp);
    if (temp) {
        return temp->value;
    } else {
        return 0;
    }
}

void valueIncrement(HashMap** map, char* key) {
    HashMap *temp;
    HASH_FIND(hh, *map, key, sizeof(char ), temp);
    if (temp) {
        temp->value++;
    } else {
        temp = malloc(sizeof(HashMap));
        temp->key = *key;
        temp->value = 1;
        HASH_ADD(hh, *map, key, sizeof(char), temp);
    }
}


char* subString(char* str, int start, int length) {
    char *sub = calloc(length + 1, sizeof(char));
    for (int i = 0; i < length; ++i) {
        sub[i] = str[start + i];
    }
    sub[length] = '\0';
    return sub;
}

char* minWindow(char* s, char* t) {
    HashMap* window = NULL, * need = NULL, * temp;
    int sLength = strlen(s), tLength = strlen(t);
    for (int i = 0; i < tLength; ++i) {
        valueIncrement(&need, t + i);
    }
    int left = 0, right = 0, valid = 0, start = 0, length = INT_MAX;
    while (right < sLength) {
        char c = s[right++];
        HASH_FIND(hh, need, &c, sizeof c, temp);
        if (temp) {
            valueIncrement(&window, &c);
            if (getValueFromHashMap(window, &c) == getValueFromHashMap(need, &c)) {
                ++valid;
            }
        }

        while (valid == HASH_COUNT(need)) {
            if (right - left < length) {
                start = left;
                length = right - start;
            }
            char ch = s[left++];
            HASH_FIND(hh, need, &ch, sizeof ch, temp);
            if (temp) {
                if (getValueFromHashMap(window, &ch) == getValueFromHashMap(need, &ch)) {
                    --valid;
                }
                HASH_FIND(hh, window, &ch, sizeof ch, temp);
                temp->value--;
            }
        }
    }
    return length == INT_MAX ? "" : subString(s, start, length);
}


bool checkInclusion(char* s1, char* s2) {
    HashMap* window = NULL, * need = NULL, * temp;
    int s1Length = strlen(s1), s2Length = strlen(s2);
    for (int i = 0; i < s1Length; ++i) {
        valueIncrement(&need, s1 + i);
    }
    int left = 0, right = 0, valid = 0;
    while (right < s2Length) {
        char c = s2[right++];
        HASH_FIND(hh, need, &c, sizeof c, temp);
        if (temp) {
            valueIncrement(&window, &c);
            if (getValueFromHashMap(window, &c) == getValueFromHashMap(need, &c)) {
                ++valid;
            }
        }

        while (right - left >= s1Length) {
            if (valid == HASH_COUNT(need)) {
                return true;
            }
            char ch = s2[left++];
            HASH_FIND(hh, need, &ch, sizeof ch, temp);
            if (temp) {
                if (getValueFromHashMap(window, &ch) == getValueFromHashMap(need, &ch)) {
                    --valid;
                }
                HASH_FIND(hh, window, &ch, sizeof ch, temp);
                temp->value--;
            }
        }
    }
    return false;
}


int* findAnagrams(char * s, char * p, int* returnSize){
    HashMap* window = NULL, * need = NULL, * temp;
    int pLength = strlen(p), sLength = strlen(s);
    for (int i = 0; i < pLength; ++i) {
        valueIncrement(&need, p + i);
    }
    int left = 0, right = 0, valid = 0, capacity = 1000;
    *returnSize = 0;
    int *res = calloc(capacity, sizeof capacity);
    while (right < sLength) {
        char c = s[right++];
        HASH_FIND(hh, need, &c, sizeof c, temp);
        if (temp) {
            valueIncrement(&window, &c);
            if (getValueFromHashMap(window, &c) == getValueFromHashMap(need, &c)) {
                ++valid;
            }
        }

        while (right - left >= pLength) {
            if (valid == HASH_COUNT(need)) {
                if (*returnSize + 1 > capacity) {
                    capacity += 10;
                    realloc(res, capacity * sizeof(capacity));
                }
                res[*returnSize] = left;
                (*returnSize)++;
            }
            char ch = s[left++];
            HASH_FIND(hh, need, &ch, sizeof ch, temp);
            if (temp) {
                if (getValueFromHashMap(window, &ch) == getValueFromHashMap(need, &ch)) {
                    --valid;
                }
                HASH_FIND(hh, window, &ch, sizeof ch, temp);
                temp->value--;
            }
        }
    }
    return res;
}

int lengthOfLongestSubstring(char* s) {
    // hashmap 的map初始必须设为NULL
    HashMap* map = NULL, * temp = NULL;
    int length = strlen(s), left = 0, right = 0, res = 0;
    while (right < length) {
        char c = s[right];
        HASH_FIND(hh, map, &c, sizeof c, temp);
        if (temp) {
            temp->value++;
        } else {
            temp = malloc(sizeof(HashMap));
            temp->key = c;
            temp->value = 1;
            HASH_ADD(hh, map, key, sizeof c, temp);
        }
        right++;
        while (temp->value > 1) {
            char ch = s[left];
            HashMap *node;
            HASH_FIND(hh, map, &ch, sizeof ch, node);
            node->value--;
            ++left;
        }
        res = (res > right - left ? res : right - left);
    }
    return res;
}

int main() {
//    char s[] = {'a', '\0'};
//    char t[] = {'a', 'a',  '\0'};
//    printf("%s\n", minWindow(s, t));
//    int returnSize;
//    findAnagrams("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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